# -*- coding:utf-8 -*-
# @FileName  :dhcc_per_6_report_save_print.py
# @Time      :2020/12/22 15:24
# @Author    :Zhoujirong
# @Desc      :个人报告保存打印

import time
from common.log import Log
from biz.flow.per_report import PerReportRequest
from biz.cases.base_case import BaseCase
from common.utils import download

class TestPerReportSavePrint(BaseCase):
    data_file_name = ''
    @classmethod
    def setUpClass(cls) -> None:
        cls.cookie = BaseCase().get_token()

    def test_save(self):
        '''保存报告'''
        creditId = ''
        recordId = BaseCase().per_get_recordid()
        ret = PerReportRequest.save(creditId,recordId,self.cookie)
        Log.info(ret)
        size = download('个人信用报告保存dhcc_per_6_report_save_printDtest_save%s.pdf'%time.strftime('%Y%m%d%H%M%S',time.localtime()),ret)
        Log.info('文件大小为:%s' % size)
        self.assertNotEqual(0, size)

    def test_queryreportstatus(self):
        '''状态'''
        creditId = ''
        recordId = BaseCase().per_get_recordid()
        ret = PerReportRequest.queryreportstatus(creditId, recordId, self.cookie)
        Log.info(ret)
        self.assertEqual(True,ret)

    def test_saverrintLog(self):
        '''保存写日志'''
        recordId = BaseCase().per_get_recordid()
        ret = PerReportRequest.saverrintLog(recordId, self.cookie)
        Log.info(ret)
        self.assertEqual('00000000',ret.code)
        self.assertIn('保存成功',ret.msg)

    def test_printreport(self):
        '''打印报告跳转'''
        creditId = ''
        recordId = BaseCase().per_get_recordid()
        ret = PerReportRequest.printreport(creditId, recordId, self.cookie)
        Log.info(ret)
        self.assertIn('打印报告',ret)

    def test_savepdfandresurl(self):
        '''pdf的url'''
        creditId = ''
        recordId = BaseCase().per_get_recordid()
        ret = PerReportRequest.savepdfandresurl(creditId, recordId, self.cookie)
        Log.info(ret)
        self.assertIn('static/pdfReport/',ret)




if __name__ == "__main__":
    pass